package ioperations;
import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOPeration{
    public void work(BookList bookList){
        System.out.println("借阅图书.....");
        System.out.println("请输入你要借阅的图书");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.GetUsedSize() ; i++) {
            Book book = bookList.books[i];
            if(book.getName().equals(name)){
                if(book.GetIsborrowed()==true){
                    System.out.println("该书已经被借出");
                    return;
                }
                book.setIsborrowed(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("这里没有你要借的书");
    }
}
